/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package deatax.display.particle;

/**
 *
 * @author nrechten
 */
public class ScaleRule extends ParticleRule {


    public ScaleRule(float derivative, float min, float max) {
        this.derivative = derivative;
        this.min = min;
        this.max = max;
    }

    @Override
    public void apply(float[] f, int index, int index_r, float scale, float[] p, float age) {
        f[index_r] = Math.min(Math.max(f[index_r]+derivative*scale,min),max);
        p[2] = f[index_r];
    }

    @Override
    public void init(float[] f, int index) {
        f[index] = derivative>0?min:max;
    }

}
